<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<button>abort</button>
<button>取消</button>
</body>
<script>
    const btns = document.querySelectorAll("button");
    let xhr = null;
    btns[0].onclick = function(){
        if(xhr)
            xhr.abort();
        xhr = new XMLHttpRequest();
        xhr.open("get","http://zhangpeiyue.com/scoreList");
        xhr.send();
        xhr.onload = function(){
            console.log(xhr.response);
        }
    }
    btns[1].onclick = function(){
        if(xhr)
            xhr.abort();
    }
</script>
</html>